import React, { Component } from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import { Modal, Header, Button, Icon } from 'semantic-ui-react'
import { projectLabelView as projectDuck } from 'ducks'

class DeleteAllView extends Component {
  render() {
    const { isDeleteAllModalOpen, deleteAllStart, closeDeleteAllModal } = this.props
    return (
      <Modal open={isDeleteAllModalOpen} basic size='tiny'>
        <Header icon='trash' content='Delete labels' />
        <Modal.Content>
          <p >All the labels of this item will be deleted.</p>
        </Modal.Content>
        <Modal.Actions>
          <Button basic color='red' inverted onClick={closeDeleteAllModal}>
            <Icon name='remove' /> No
          </Button>
          <Button color='green' inverted onClick={()=>deleteAllStart(projectDuck.creators.actionDeleteAllServer)}>
            <Icon name='checkmark' /> Yes
          </Button>
        </Modal.Actions>
      </Modal>
    )
  }
}

const mapStateToProps = state => ({
  isDeleteAllModalOpen: projectDuck.selectors.isDeleteAllModalOpen(state),
})

const mapDispatchToProps = {
  deleteAllStart: projectDuck.creators.actionResetEditAndDo,
  closeDeleteAllModal: projectDuck.creators.actionCloseDeleteModal,
}

export default connect(mapStateToProps, mapDispatchToProps)(DeleteAllView)


